var chat = new Vue({
	el: '#chat',
	data: {
		env:[],
		info:[]
	},
	mounted: function() {
		this.locallist()
	},
	methods: {
		locallist:function(){
			var _this = this
			_this.env = []
			_this.info = []
			db.transaction(function(tx) {
					
					tx.executeSql('SELECT * FROM area group by id', [], function(tx, results) {
						if(results.rows.length != null) {
							for(var i=0;i<results.rows.length;i++){
								_this.env.push({id:results.rows.item(i).id,name:"环境表单   "+results.rows.item(i).id})
							}
						}
					}, null);
					tx.executeSql('SELECT * FROM info group by id', [], function(tx, results) {
						if(results.rows.length != null) {
							for(var i=0;i<results.rows.length;i++){
								_this.info.push({id:results.rows.item(i).id,name:"产品表单   "+results.rows.item(i).id})
							}
						}
					}, null);
				});
		},
		deleteinfo:function(id){
				var _this = this
  		var btnArray = ['确定', '取消'];
				mui.confirm('该表单未提交，是否确认删除?', '提示', btnArray, function(e) {
					if (e.index == 1) {
						return
					} else {
					//删除本地数据库
					 db.transaction(function(tx) {
    					tx.executeSql('DELETE FROM info WHERE id=?', [id]);
					});
					
					_this.locallist();
					}
				})
		},
		deleteenv:function(id){
				var _this = this
  		var btnArray = ['确定', '取消'];
				mui.confirm('该表单未提交，是否确认删除?', '提示', btnArray, function(e) {
					if (e.index == 1) {
						return
					} else {
							//删除本地数据库
					 db.transaction(function(tx) {
    					tx.executeSql('DELETE FROM area WHERE id=?', [id]);
					});
					_this.locallist();
					}
				})
		},
		toenv:function(id){
			window.location.href = 'localEnvForm.html?id='+id
		},
		toinfo:function(id){
			window.location.href = 'localInfoForm.html?id='+id
		}

	},
});